package br.com.automed.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="CM_AREA_MEDICA")
@NamedQueries({
	@NamedQuery(name="listarAreaMedica", query="FROM AreaMedica a ORDER BY a.areaMedica"),
	@NamedQuery(name="buscarAreaMedica", query="FROM AreaMedica a where a.areaMedica = :param")
})
public class AreaMedica {

	public static final String NAMED_QUERY_LIST_AREA_MEDICA = "listarAreaMedica";
	public static final String NAMED_QUERY_BUSCAR_AREA_MEDICA = "buscarAreaMedica";
	
	@Id
    @GeneratedValue(generator = "system-uuid", strategy=GenerationType.AUTO)
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "ID_AREA_MEDICA")
	private String idAreaMedica;
	
	@Column(name = "ST_AREA_MEDICA")
	private String areaMedica;
	
	@OneToOne(mappedBy="especialidade")
	private Medico medico;

	public String getIdAreaMedica() {
		return idAreaMedica;
	}

	public void setIdAreaMedica(String idAreaMedica) {
		this.idAreaMedica = idAreaMedica;
	}

	public String getAreaMedica() {
		return areaMedica;
	}

	public void setAreaMedica(String areaMedica) {
		this.areaMedica = areaMedica;
	}

	public Medico getMedico() {
		return medico;
	}

	public void setMedico(Medico medico) {
		this.medico = medico;
	}
	
	@Override
	public boolean equals(Object obj) {
		AreaMedica areaMedica = (AreaMedica) obj;
		return areaMedica != null ? areaMedica.getIdAreaMedica().equals(this.getIdAreaMedica()) : null;
	}
	
	@Override
	public int hashCode() {

		return idAreaMedica.hashCode();
	}
	
	@Override
	public String toString() {
		
		return idAreaMedica;
	}
}
